<?php

	$link = mysql_connect('localhost', 'root', '');
	if (!$link) {
		die('Not connected : ' . mysql_error());
	}

	// make foo the current FinalProject
	$db_selected = mysql_select_db('FinalProject', $link);
	if (!$db_selected) {
		die ('Can\'t use Final Project: ' . mysql_error());
	}
	
	$query = sprintf("INSERT INTO %s (Content, URL, Image, Thumbnail, Parent) VALUES ('%s', '%s', '%s', '%s', '%s')",
		mysql_real_escape_string($_GET['user']),
		mysql_real_escape_string($_GET['content']),
		mysql_real_escape_string($_GET['url']),
		mysql_real_escape_string($_GET['image']),
		"",
		mysql_real_escape_string($_GET['parent']));

	// Perform Query
	  $result = mysql_query($query);

	  // Check result
	  // This shows the actual query sent to MySQL, and the error. Useful for debugging.
	  if (!$result) {
			 $message  = 'Invalid query: '.mysql_error().' ';
			 $message .= 'Whole query: '.$query;
			 die($message);
	  }
?>